package com.lee.api.client;

import com.lee.common.model.AppResult;
import com.lee.common.model.User;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

@FeignClient(value = "user-service", path = "/user")
public interface UserClient {

    @PostMapping("/register")
    public AppResult register(@RequestParam("username") String username,
                              @RequestParam("nickname") String nickname,
                              @RequestParam("password") String password,
                              @RequestParam("passwordRepeat") String passwordRepeat,
                              @RequestParam("checkcode") String checkcode);

    @PostMapping("/login")
    public AppResult login(@RequestParam("username") String username,
                           @RequestParam("password") String password,
                           @RequestParam("checkcode") String checkcode);

    @GetMapping("/info")
    public AppResult<User> getUserInfo(@RequestParam(value = "id",required = false) Long id);

    @GetMapping("/logout")
    public AppResult logout ();

    @PostMapping("/modifyInfo")
    public AppResult<User> modifyInfo(@RequestParam(value = "username",required = false) String username,
                                      @RequestParam(value = "nickname",required = false) String nickname,
                                      @RequestParam(value = "gender",required = false) Byte gender,
                                      @RequestParam(value = "email",required = false) String email,
                                      @RequestParam(value = "phoneNum",required = false) String phoneNum,
                                      @RequestParam(value = "remark",required = false) String remark);

    @ApiOperation("修改密码")
    @PostMapping("/modifyPwd")
    public AppResult modifyPassword (@RequestParam("oldPassword") String oldPassword,
                                     @RequestParam("newPassword") String newPassword,
                                     @RequestParam("passwordRepeat") String passwordRepeat);


    @ApiOperation("上传头像")
    @PostMapping("/upload")
    public AppResult<User> uploadPhoto(@RequestPart("file") MultipartFile file);

    @ApiOperation("获取验证码")
    @GetMapping("/getcode")
    public AppResult<String> getcode();

    @GetMapping("/getUserInfo")
    public AppResult<User> login();

    /**
     * 获取发信人的基本通讯信息
     * @return
     */
    @GetMapping("/getToUserInfo")
    public AppResult<User> login(@RequestParam(value = "id",required = true) Long id);

    User selectByPrimaryKey(Long receiveUserId);

    User selectById(Long receiveUserId);

    void addOneArticleCountById(Long id);

    void subOneArticleCountById(Long userId);
}
